home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / contrib / zelk / scm / remoteprocess.e < prev    next >
Encoding:
Text File  |  1992-10-17  |  2.0 KB  |  74 lines

  1. ;; remoteprocess.e zilla 17feb - manipulate remote processes
  2. ;; 4oct    sysv version
  3.  
  4. (require 'shell.e)
  5. (provide 'remoteprocess.e)
  6.  
  7. ;; kill processes on a remote machine, by name
  8. (define (remotekill mach processname)
  9.   (remoteproc mach processname "kill ~a"))
  10.  
  11.  
  12. ;; renice a process remote group
  13. ;; 'ps xl' shows the nice priority in NI column.
  14. (define (renice mach processname niceval)
  15.   (remoteproc mach processname
  16.           (format #f
  17.               "/etc/renice ~a -g ~~a" niceval))
  18. )
  19.  
  20.  
  21. ;; helper: given mach, processname, and a commandstring with one ~a,
  22. ;; get pids on the remote mach wich match processname, 
  23. ;; substitute those pids into cmd, and execute.
  24. (define (remoteproc mach processname cmd)
  25.   (if (equal? (os-architecture) "mips")
  26.       (remoteproc-sysv mach processname cmd)
  27.       (remoteproc-bsd mach processname cmd)
  28. ))
  29.  
  30. (define (remoteproc-bsd mach processname cmd)
  31.   (if (symbol? mach) (set! mach (symbol->string mach)))
  32.   (rsh (format #f "~a ps gx | grep ~a > proctmp~~" mach processname))
  33.   (call-with-input-file "proctmp~"
  34.     (lambda (f)
  35.       (let ((s (read-string f)))
  36.     (while (not (eof-object? s))
  37.       (let* ((pid (substring s 0 6))
  38.          (cmdp (format #f cmd pid)))
  39.         (format #t " remoteproc found: ~a~%" s)
  40.         (format #t " remoteproc doing rsh ~a ~a~%" mach cmdp)
  41.         (rsh mach cmdp)
  42.       )
  43.       (set! s (read-string f))
  44.     )
  45.       );let
  46.     );lambda
  47.   );call-with-input-file
  48. );remoteproc-bsd
  49.  
  50.  
  51.  
  52. (define (remoteproc-sysv mach processname cmd)
  53.   (if (symbol? mach) (set! mach (symbol->string mach)))
  54.   (rsh (format #f "~a ps -edalf | grep ~a > proctmp~~" mach processname))
  55.   (call-with-input-file "proctmp~"
  56.     (lambda (f)
  57.       (let ((s (read-string f)))
  58.     (while (not (eof-object? s))
  59.       (let* ((pid (substring s 14 20))
  60.          (cmdp (format #f cmd pid)))
  61.         (format #t " remoteproc found: ~a~%" s)
  62.         (format #t " remoteproc doing rsh ~a ~a~%" mach cmdp)
  63.         (rsh mach cmdp)
  64.       )
  65.       (set! s (read-string f))
  66.     )
  67.       );let
  68.     );lambda
  69.   );call-with-input-file
  70. );remoteproc-sysv
  71.  
  72.  
  73.  
  74.